package com.meow_woof.mapper;

import com.github.pagehelper.Page;
import com.meow_woof.annotation.AutoFill;
import com.meow_woof.dto.DishPageQueryDTO;
import com.meow_woof.entity.Dish;
import com.meow_woof.enumeration.OperationType;
import com.meow_woof.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);
    @AutoFill(value= OperationType.INSERT)
    void insert(Dish dish);



    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id}")
    Dish selectById(Long id);

    /**
     * 根据id删除
     * @param ids
     */

    void deleteByIds(List<Long> ids);
    @Select("select * from dish where id=#{id}")
    DishVO selectByIdWithFlavour(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> selectByCondition(Dish dish);

    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
